package edu.ycu.aladdin.web.service.impl;

import edu.ycu.aladdin.common.dao.NewsDataDao;
import edu.ycu.aladdin.web.dao.OauthDao;
import edu.ycu.aladdin.web.dto.DataLabel;
import edu.ycu.aladdin.web.service.LabelService;
import org.springframework.stereotype.Service;

/**
 * @author <a href="mailto:wangruihuano@gmail.com">王瑞环</a>
 * @since 1.0
 */
@Service
public class LabelServiceImpl implements LabelService {

    private final OauthDao oauthDao;
    private final NewsDataDao newsDataDao;

    public LabelServiceImpl(OauthDao oauthDao, NewsDataDao newsDataDao) {
        this.oauthDao = oauthDao;
        this.newsDataDao = newsDataDao;
    }

    @Override
    public void labelData(DataLabel label, String sso) {

        String uid=oauthDao.getUserId(sso);
        String newsId = label.getNewsId();
        label.setLabeler(uid);
        newsDataDao.addLabel(newsId,label);
    }
}
